/***************************************************************************
 *   hmp.h                                                                 *
 *   Created on 9 wrzesień 2009, 10:56                                     *
 *   Copyright (C) 2009 by cmaster.matso (Maciej Kadłubowski)              *
 *   cmaster.matso@gmail.com                                               *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef _HEIGHTMAP_H
#define	_HEIGHTMAP_H

#ifdef	__cplusplus
extern "C" {
#endif

#include "../../math/src/mgpi_math.h"

#pragma pack(push,1)

    typedef struct _hmp {
        float4 *vertex_array;
        float3 *tangent_array;
        float3 *normal_array;
        float2 *tex_coords_array;
        unsigned int *index_array;
        int num_vertices;
        int num_indices;

        /* V ??? V */
        float width, height;
        float3 scale;
    } hmp_t;

#pragma pack(pop)

    int MGPI_API gsubReadHMPModel(const char *filename, hmp_t *hmp);
    int MGPI_API gsubRenderHMPModel(const hmp_t *hmp);
    void MGPI_API gsubFreeHMPModel(hmp_t *hmp);

    void MGPI_API gsubSetTexCoordsWrapping(float x, float y);
    MGPI_BOOL MGPI_API gsubIsOnMapv(hmp_t *hmp, float2 position);
    MGPI_BOOL MGPI_API gsubIsOnMapf(hmp_t *hmp, float x, float y);
    void MGPI_API gsubGetNormalv(hmp_t *hmp, float4 *pnormal, float2 position);
    void MGPI_API gsubGetNormalf(hmp_t *hmp, float4 *pnormal, float x, float y);
    void MGPI_API gsubGetHeightv(hmp_t *hmp, float *pheight, float2 position);
    void MGPI_API gsubGetHeightf(hmp_t *hmp, float *pheight, float x, float y);

#ifdef	__cplusplus
}
#endif

#endif	/* _HEIGHTMAP_H */

